$(function () {
    var amount_rate = 0.02;
    function createPayQRCode(url) {
        $("#qrcode_pay").qrcode({
            width: 150,
            height: 150,
            text: url
        });
    }
  
	//***
    $("#recharge").on("click", function () {
        var amount = $("#amount");
        var value = amount.val();
      
            $("#modal_confirm").show();
       
    });
	//***
    $("#recharge_confirm").on("click", function () {
           var amount = $("#amount").text();
		  var order_code = 's1462951762966238';
           var pay_url = 'weixin:\/\/wxpay\/imlixiang';
		   $("#recharge_order_no").text(order_code);
           createPayQRCode(pay_url);
           pay();
    });
    function pay() {
        $("#modal_pay").show();
        $("#modal_confirm").hide();  
        $.getJSON(basePath+"/order/updateorder",{"orderId":orderId}, function (resp) {
               setTimeout(function () {
          	     paySucess();
                 console.log("充值订单支付成功:" + new Date().format("yyyy/MM/dd hh:mm:ss"));
             }, 3000);
        });
     
             
           
                  /*  payFailed(data);
                    console.log("充值订单支付失败:" + new Date().format("yyyy/MM/dd hh:mm:ss"), data);*/
         
                 /*   payFailed(data);
                    console.log("充值订单支付失败:" + new Date().format("yyyy/MM/dd hh:mm:ss"), data);
               */
      
    }
    function paySucess() {
        toastr.success("支付完成");
        $("#modal_pay").hide();
        $("#modal_result").show();
        $("span[data-type=recharge_amount_real]").text();
        $("#modal_result_sucess").show();
        $("#modal_result_failed").hide();
    };
    function payFailed(r) {
        toastr.error("支付失败！请重试");
        $("#modal_pay").hide();
        $("#modal_result").show();
        $("#modal_result_sucess").hide();
        $("#modal_result_failed").show();
    }
    $("#result_sucess").click(function () {
        window.location.href =basePath+"/student/sub6";
    });
    $("#result_failed").click(function () {
        $("#modal_result").hide();
        pay();
    });
    $("#pay_cancel,#result_cancel,#recharge_cancel").click(function () {
        window.location.href = window.location.href;
    });
});